import request from '@/utils/request'
import type { Device, DeviceQuery, DeviceForm, PaginationResponse } from '@/types'

// 获取设备列表
export const getDeviceList = (params: DeviceQuery): Promise<PaginationResponse<Device>> => {
  return request.get('/devices', { params })
}

// 获取设备详情
export const getDeviceDetail = (id: number): Promise<Device> => {
  return request.get(`/devices/${id}`)
}

// 创建设备
export const createDevice = (data: DeviceForm): Promise<void> => {
  return request.post('/devices', data)
}

// 更新设备
export const updateDevice = (id: number, data: DeviceForm): Promise<void> => {
  return request.put(`/devices/${id}`, data)
}

// 删除设备
export const deleteDevice = (id: number): Promise<void> => {
  return request.delete(`/devices/${id}`)
}

// 获取设备统计
export const getDeviceStats = (): Promise<any> => {
  return request.get('/devices/statistics')
}

// 获取设备监控数据
export const getDeviceMonitor = (): Promise<any> => {
  return request.get('/devices/monitor')
}

// 获取设备地图数据
export const getDeviceMap = (): Promise<Device[]> => {
  return request.get('/devices/map')
}